<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<div class="t_bar">${param.title }</div>
	<table  id="tblAttendOrg" cellpadding="0" class="table01 t_css" width="100%" border="0" cellpadding="0" style="*border-bottom: #a1c0dc 1px solid;">
		<thead >
					<tr style="border:1px solid #B7D1E6">
						<th class="TblHead" align="center" rowspan="2"  width="5%">选择</th>
						<th class="TblHead" align="center" rowspan="2"   width="5%">序号</th>
						<th class="TblHead" align="center" rowspan="2"   width="10%">单位名称</th> 
						<th class="TblHead" align="center" rowspan="2"   width="10%">单位地址</th>  
				        <th class="TblHead" align="center" rowspan="2"   width="10%">项目联系人</th> 
				        <th class="TblHead" align="center" rowspan="2"   width="10%">联系电话</th>     
						<th class="TblHead" align="center" rowspan="2"   width="10%">单位性质</th> 
						<th class="TblHead" align="center" rowspan="2"   width="10%">组织机构代码</th>     
						<th class="TblHead" align="center" rowspan="2"   width="10%">Email地址</th>     
						<th class="TblHead" align="center" colspan="2" width="10%">经费预算分配情况</th>                
					</tr>
					<tr>
					<th class="TblHead" align="center"  width="10%">总经费<br/>（万元）</th>
					<th class="TblHead" align="center"  width="10%">省财政经费（万元）</th>
					</tr>
			</thead>
			<tbody id="tab">
					<tr style="display:none" >
						<td align="center">&nbsp;
							<input type="radio" class="radiobutton" name="selAttendOrg" >
							<input type="hidden" name="attendorgs|attendorg[0]|mobile" /> 
							<input type="hidden" name="attendorgs|attendorg[0]|work_divide" /> 
							<input type="hidden" name="attendorgs|attendorg[0]|work_divide_hidden" /> 
							<!-- <input type="hidden" name="attendorgs|attendorg[0]|nature_code" />  -->
							<input type="hidden" name="attendorgs|attendorg[0]|nature_value" /> 
							
							
							
							<!-- 所合作国别和地区 -->
							<input type="hidden" name="attendorgs|attendorg[0]|cooperation_area_value" />
							<input type="hidden" name="attendorgs|attendorg[0]|cooperation_area_name" />  
							<!-- 所属省份 -->
							<input type="hidden" name="attendorgs|attendorg[0]|province_value" />
							<input type="hidden" name="attendorgs|attendorg[0]|province_name" />
							
							
							
						</td>
						<td align="center">
							<span name="attendorgs|attendorg[0]@seq_no" >[index]</span> 
						</td>
						<td align="left">
						<span name="attendorgs|attendorg[0]|cname"  label="单位名称" ></span>
						</td>
						<td align="left">
						<span name="attendorgs|attendorg[0]|address"  label="单位地址" ></span>
						</td>
						<td align="center"><span name="attendorgs|attendorg[0]|contact_psn_name"  label="联系人"  ></span>
						</td>
						<td align="center"><span name="attendorgs/attendorg[0]|contact_psn_tel"  label="联系电话" ></span>
						</td>
						<td align="center"><span name="attendorgs|attendorg[0]|nature_name"  label="注册类型" ></span>
						</td>
						<td align="center"><span name="attendorgs|attendorg[0]|org_no"  label="组织机构代码" ></span>
						</td>
						<td align="center"><span name="attendorgs|attendorg[0]|email"  label="Email地址" ></span>
						</td>
						<td align="center"><span name="attendorgs|attendorg[0]|fund_all"  label="总经费"  ></span>
						</td>
						<td align="center"><span name="attendorgs|attendorg[0]|province_fund"  label="省财政经费"  ></span>
						</td>
				</tr>
				<c:set value="0" var="index" scope="page"/>
					<x:forEach select="$xmlData/data/attendorgs/attendorg" var="attendorg">
					
					<c:choose>
						<c:when test="${index<10}" ><c:set value="0" var="flag" scope="page"/></c:when>
						<c:otherwise><c:set value="" var="flag" scope="page"/></c:otherwise>
					</c:choose>
					<tr>
						<td>&nbsp;
							<input type="radio" class="radiobutton" name="selAttendOrg" >
							<input type="hidden" name="attendorgs/attendorg[${flag}${index}]/mobile" value="<x:out select="$attendorg/mobile"/>" /> 
							<input type="hidden" name="attendorgs/attendorg[${flag}${index}]/work_divide" value="<x:out select="$attendorg/work_divide"/>"/> 
							<input type="hidden" name="attendorgs/attendorg[${flag}${index}]/work_divide_hidden" value="<x:out select="$attendorg/work_divide_hidden"/>"/> 
							<%-- <input type="hidden" name="attendorgs/attendorg[${flag}${index}]/nature_code" value="<x:out select="$attendorg/nature_code"/>"/>  --%>
						  <input type="hidden" name="attendorgs/attendorg[${flag}${index}]/nature_value" value="<x:out select="$attendorg/nature_value"/>"/> 
						
						    <!-- 所合作国别和地区 -->
						  <input type="hidden" name="attendorgs/attendorg[${flag}${index}]/cooperation_area_value" value="<x:out select="$attendorg/cooperation_area_value"/>"/> 
							<input type="hidden" name="attendorgs/attendorg[${flag}${index}]/cooperation_area_name" value="<x:out select="$attendorg/cooperation_area_name"/>"/> 
						    <!-- 所属省份 -->
						  <input type="hidden" name="attendorgs/attendorg[${flag}${index}]/province_value" value="<x:out select="$attendorg/province_value"/>"/> 
							<input type="hidden" name="attendorgs/attendorg[${flag}${index}]/province_name" value="<x:out select="$attendorg/province_name"/>"/> 
						
						
						
						
						</td>
						<td align="center">
							<span   name="attendorgs/attendorg[${flag}${index}]@seq_no" ><x:out select="$attendorg/@seq_no"/></span> 
						</td>
						<td align="left">
						<span name="attendorgs/attendorg[${flag}${index}]/cname"  label="单位名称" ><x:out select="$attendorg/cname"/></span>
						</td>
						<td align="left">
						<span name="attendorgs/attendorg[${flag}${index}]/address"  label="单位地址" ><x:out select="$attendorg/address"/></span>
						</td>
						<td align="center"><span name="attendorgs/attendorg[${flag}${index}]/contact_psn_name"  label="联系人"><x:out select="$attendorg/contact_psn_name"/></span>
						</td>
						<td align="center"><span name="attendorgs/attendorg[${flag}${index}]/contact_psn_tel"  label="联系电话" ><x:out select="$attendorg/contact_psn_tel"/></span>
						</td>
						<td align="center"><span name="attendorgs/attendorg[${flag}${index}]/nature_name"  label="注册类型" ><x:out select="$attendorg/nature_name"/></span>
						</td>
						<td align="center"><span name="attendorgs/attendorg[${flag}${index}]/org_no"  label="组织机构代码" ><x:out select="$attendorg/org_no"/></span>
						</td>
						<td align="center"><span name="attendorgs/attendorg[${flag}${index}]/email"  label="Email地址" ><x:out select="$attendorg/email"/></span>
						</td>
						<td align="center"><span name="attendorgs/attendorg[${flag}${index}]/fund_all"  label="总经费" ><x:out select="$attendorg/fund_all"/></span>
						</td>
						<td align="center"><span name="attendorgs/attendorg[${flag}${index}]/province_fund"  label="省科技厅经费" ><x:out select="$attendorg/province_fund"/></span>
						</td>
						</tr>
					<c:set value="${index+1}" var="index" scope="page"/>
					</x:forEach>
				</tbody>
			</table>
			<br/>
					<table width="98%" align="center"  border="0" cellpadding="0" cellspacing="1">
					<tr >
					<input class="button_02" type="button" name="cmdAddbefore" value="添加" onclick="if(checkTabLimit('tblAttendOrg',20,'参与（合作）单位分工情况最多只能填写20条')){addNewRow('tblAttendOrg','${ctx}/proposal/edit/dialog/orgInfoEdit_5511kjhzly_2016?parentTab=tblAttendOrg&type=add&needMeetingInfo=${param.needMeetingInfo}&TB_iframe=true&height=440&width=900','参与（合作）单位分工情况');}try{top.resizeFrame();}catch(e){};">
				&nbsp;<input class="button_02"   name="cmdMovePrev" type="button" value="上移" onclick="movePrev2('tblAttendOrg');">
				&nbsp;<input class="button_02"   name="cmdMoveNext"  type="button" value="下移" onclick="moveNext2('tblAttendOrg');">
				&nbsp;<input class="button_02"  id="cmdEdit" type="button" value="编辑" onclick="editRow('tblAttendOrg','${ctx}/proposal/edit/dialog/orgInfoEdit_kjhzly_2016?parentTab=tblAttendOrg&type=edit&needMeetingInfo=${param.needMeetingInfo}&TB_iframe=true&height=440&width=900','参与（合作）单位分工情况')">
				&nbsp;<input class="button_02"  name="cmddel" type="button" value="删除" onclick="deleteSelectedRow2('tblAttendOrg','参与（合作）单位分工情况');"></td>
	</tr>
	</table>
<br/>
<script type="text/javascript">
   function addClass(str,obj){
	   if($(obj).val().trim()!=''){
		   if(str=='attendorg[01]'){
			   $("#attendorg_01").css("display","");
		   }else if(str=='attendorg[00]'){
			   $("#attendorg_00").css("display","");
		   }else{
			   $("#"+str).css("display","");
		   }
		  $("#coopOrgInfo").find("input[name*='"+str+"'],textarea[name*='"+str+"']").addClass("required");
		  $("#coopOrgInfo").find("input[name*='"+str+"'][name$='nature_name']").removeClass("required");
		  $("#coopOrgInfo").find("input[name*='"+str+"'][name$='nature2_name']").removeClass("required");
		  $("#coopOrgInfo").find("input[name*='"+str+"'][name$='work_divide_hidden']").removeClass("required");
	   }else{
		   var flag=false;
		   $("#coopOrgInfo").find("input[name*='"+str+"'],textarea[name*='"+str+"']").each(function(){
			   if($(this).attr("name").indexOf("@seq_no")==-1){
				   if($(this).val().trim()!=''){
					   flag=true;
				   } 
			   }
		   });
		   if(flag){
			   if(str=='attendorg[01]'){
				   $("#attendorg_01").css("display","");
			   }else if(str=='attendorg[00]'){
				   $("#attendorg_00").css("display","");
			   }else{
				   $("#"+str).css("display","");
			   }
			   $("#coopOrgInfo").find("input[name*='"+str+"'],textarea[name*='"+str+"']").removeClass("required");
			   $("#coopOrgInfo").find("input[name*='"+str+"'],textarea[name*='"+str+"']").addClass("required");
			   $("#coopOrgInfo").find("input[name*='"+str+"'][name$='nature_name']").removeClass("required");
			   $("#coopOrgInfo").find("input[name*='"+str+"'][name$='nature2_name']").removeClass("required");
			   $("#coopOrgInfo").find("input[name*='"+str+"'][name$='work_divide_hidden']").removeClass("required");
		   }else{
			   if(str=='attendorg[01]'){
				   $("#attendorg_01").css("display","none");
			   }else if(str=='attendorg[00]'){
				   $("#attendorg_00").css("display","none");
			   }else{
				   $("#"+str).css("display","none");
			   }
			   $("#coopOrgInfo").find("input[name*='"+str+"'],textarea[name*='"+str+"']").removeClass("required");
		   }
	   }
   }
   function deleteSelectedRow2(tableId,message,nummin,warnMsg,selName){
		if(!selName)selName="";
		var tr=$("#"+tableId+" :radio[name*='"+selName+"']:checked").parents("tr");
		if(nummin==null)
			nummin=0;
		var length=tr.length;
		if(tr.length==0)
			tr=$("#"+tableId+" tr").filter(":last");
		else if(tr.length>1)
			tr=tr.first();

		if(tr.get(0).rowIndex-1==nummin){
			scmWarn(irisNotes.delWarn1);
			return false;
		}
		if(length==0){
			
				scmWarn(irisNotes.delWarn2);
			
			return false;
		}
		  if(!confirm(messageTip.deleteTip+message+"？"))
			  return false;
		  tr.remove();
		  refreshRowINdex2(tableId);
		  return true;
	}
   function refreshRowINdex2(tblId){
		 //重新计算行号

		
		  $("#"+tblId+" tr").each(function(){
			  
			   var seq=$(this).get(0).rowIndex;//获得行数
			   if(seq>2){//如果有行  显示时display行不计入类，故只减1
				   
				   seq=seq-2;
				   var seq_no=$(this).find("[name$='seq_no']");
				   if(seq_no.is("span"))
					   seq_no.html(seq);
				   else
					   seq_no.val(seq);
				   
				   seq=""+(seq-1);
				   if(seq.length==1)
					   seq="0"+seq;
				  //替换相应的name参数的seq
				  $(this).find("input,span,textarea,select").each(function(){
					   var name=$(this).attr("name");
					   if(name!=null&&name!=""){
						   name=name.replace(/\[\d*\]/g,"["+seq+"]");
						   $(this).attr("name",name);
					   }
					   var id=$(this).attr("id");
					   if(id!=null&&id!=""){
						   id=id.replace(/\[\d*\]/g,"["+seq+"]");
						   $(this).attr("id",id);
						   id=id.replace(/\d+/g,""+seq+"");
						   $(this).attr("id",id);
					   }
					   var className=$(this).attr("class");
					   if(className!=null&&className!=""){
						   className=className.replace(/\[\d*\]/g,"["+seq+"]");
						   $(this).attr("class",className);
					   }
				   });
			   }
			 }
		  );

	}
   /**
    * 上移行
    * @param tblId
    * @returns {Boolean}
    */
   function movePrev2(tblId,selName) {

   	if (!selName)
   		selName = "";
   	if ($("#" + tblId + " :radio[name*='" + selName + "']:checked").length == 0) {
   		scmWarn(irisNotes.prevWarn);
   		return false;
   	}
   	if ($("#" + tblId + " tr").length <= 3)
   		return false;
   	var trChecked = $("#" + tblId + " :radio[name*='" + selName + "']:checked")
   			.parents("tr").first();// 取得被选中的行
   	var trPrev = trChecked.prev();// 取得上一行
   	var index = trChecked.get(0).rowIndex;// 获得行号
   	if (index <= 3) {// 如果是第一行
   		scmWarn(irisNotes.tabelMoveWarn1);
   		return false;
   	}
   	//trChecked.remove();
   	trPrev.before(trChecked);
   	trChecked.find(":radio[name*='" + selName + "']").attr("checked", 'true');
   	refreshRowINdex2(tblId);
   }

   /**
    * 下移行
    * @param tblId
    * @returns {Boolean}
    */
   function moveNext2(tblId,selName) {
   	if (!selName)
   		selName = "";
   	if ($("#" + tblId + " :radio[name*='" + selName + "']:checked").length == 0) {
   		scmWarn(irisNotes.nextWarn);
   		return false;
   	}
   	if ($("#" + tblId + " tr").length <= 3) {
   		return false;
   	}
   	var trChecked = $("#" + tblId + " :radio[name*='" + selName + "']:checked")
   			.parents("tr").first();// 取得被选中的行
   	var trNext = trChecked.next();
   	var index = trChecked.get(0).rowIndex;// 获得行号
   	if (index == $("#" + tblId + " tr").length - 1) {// 如果是第一行
   		scmWarn(irisNotes.tabelMoveWarn2);
   		return false;
   	}
   	//trChecked.remove();
   	trNext.after(trChecked);
   	trChecked.find(":radio[name*='" + selName + "']").attr("checked", "true");
   	refreshRowINdex2(tblId);
   }

   $(document).ready(function(){
	  // addClass('org_cooperate3',$("#org_name3"));
	   //addClass('attendorg[01]',$("#org_name2"));
	  // addClass('attendorg[00]',$("#org_name1"));
	  $("#tblAttendOrg").each(function(){
	  		$(this).find("tr:even").addClass("li_1");
	  		$(this).find("tr:odd").addClass("li_2");
	  	});
	});
</script>